<?php

/**
 * Tag
 * 
 * @author Oliver Schwarz <oliver.schwarz@gmail.com>
 * @package Controller
 */
class Tag
{

        private $oTpl, $aUser;
        public function __construct()
        {
                $this->oTPL = TPL::getInstance();
                $this->aUser = Auth::check();
        }
        public function getTagcloud()
        {

                $sql = sprintf("
                        SELECT tag, quantity FROM %s ORDER BY quantity DESC LIMIT 20",
                        'tags');
                $res = DB::get($sql);
                foreach ($res as $k => $v):
                        $sum[] = $v['quantity'];
                endforeach;
                $mysum = array_sum($sum);
                foreach ($res as $k => $v):
                        $tags[$v['tag']] = $v;
                        $tags[$v['tag']]['size'] = round($v['quantity']/$mysum * 10);  
                endforeach;
                return $tags;

        }

}

?>